#!/usr/bin/env node
'use strict';

const Koa = require('koa');
/**
 * load environment variable first
 */
require('dotenv').load();

/**
 * configuration and router
 */
const router = require('./routes');
const config = require('./config');

const app = new Koa();

config(app);
app.use(router.routes());

const port = process.env.PORT || 8900;

app.listen(port, err => {
	if (err) {
		throw err;
	}

	console.log('App started on:', port);
});

module.exports = app;
